<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>sline: C:/Users/zhu/Desktop/sline/Component/sline.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">sline<span id="projectnumber">&#160;v1.1.1</span>
   </div>
   <div id="projectbrief">This is a shell component.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_84f5943c2b4a25d8438a76cb00d93649.html">zhu</a></li><li class="navelem"><a class="el" href="dir_e8238830557e247603cce3caaa85a16c.html">Desktop</a></li><li class="navelem"><a class="el" href="dir_db193841dc67b21f7da766c1e5f29c12.html">sline</a></li><li class="navelem"><a class="el" href="dir_53f78a5796821c1c1f32bc361eada011.html">Component</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">sline.h</div></div>
</div><!--header-->
<div class="contents">
<a href="sline_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#ifndef __SLINE_H__</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="preprocessor">#define __SLINE_H__</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="comment">/*对外api*/</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#define SL_API              extern</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="comment">/*输入字符头*/</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#define SL_HEADER           &quot;sline&gt;&quot;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="comment">/*命令行版本*/</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="comment">/*v1.1.1 - 2023.5.18    修复在历史记录切换时，填充buff为空格的问题</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="comment">                        增加函数调用的预制指令 sl_cmd_export_pre*/</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="comment">/*v1.1.0 - 2023.5.5     实现的历史记录，命令补全，预制命令等功能*/</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="comment">/*v1.0.0 - ?.?.?        只实现了指令注册等基本的简单功能*/</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="preprocessor">#define SL_VERSION          &quot;1.1.1&quot;</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="comment">/*缓冲区的长度度和个数，同时决定单个指令最大长度*/</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span><span class="preprocessor">#define SL_HIS_FIFO_LEN     256</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="preprocessor">#define SL_HIS_FIFO_NUM     10</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="comment">/*打印缓冲区长度*/</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span><span class="preprocessor">#define SL_PRINTF_NUM       1024</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="comment">/*cmds的长度*/</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span><span class="preprocessor">#define SL_CMDS_LEN         40</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="comment">/*支持指令最大参数量*/</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span><span class="preprocessor">#define SL_CMD_ARGC_MAX     10</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="comment">/*命令名字长度*/</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="preprocessor">#define SL_CMD_NAME_LEN     32</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="comment">/*命令描述长度*/</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span><span class="preprocessor">#define SL_CMD_DESC_LEN     128</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span> </div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"><a class="line" href="structsline__cmd__t.html">   50</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>{</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>    <span class="keyword">const</span> <span class="keywordtype">char</span> name[SL_CMD_NAME_LEN];</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>    int (*func)(<span class="keywordtype">int</span> argc,<span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>    <span class="keyword">const</span> <span class="keywordtype">char</span> desc[SL_CMD_DESC_LEN];</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>}<a class="code hl_struct" href="structsline__cmd__t.html">sline_cmd_t</a>;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="structsline__cmd__code__t.html">   64</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>{</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>    <span class="keyword">const</span> <span class="keywordtype">char</span> * name;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>    int (*func)(<span class="keywordtype">int</span> argc,<span class="keywordtype">char</span> *argv[]);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>    <span class="keyword">const</span> <span class="keywordtype">char</span> * desc;</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>}<a class="code hl_struct" href="structsline__cmd__code__t.html">sline_cmd_code_t</a>;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"><a class="line" href="sline_8h.html#ac30134d048f27d62b2dec7db53d0a8ea">   75</a></span><span class="preprocessor">#define SL_CMD_EXPORT(func,desc)                                        \</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span><span class="preprocessor">        const char sline_cmd_name##func[] = #func;                      \</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span><span class="preprocessor">        const char sline_cmd_desc##func[] = #desc;                      \</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span><span class="preprocessor">        __attribute__((used)) const sline_cmd_code_t sline_cmd_t_##func \</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span><span class="preprocessor">        __attribute__((section(&quot;cmd_list&quot;</span>)))= {                         \</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>        sline_cmd_name##func,                                           \</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>        (func),                                                         \</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>        sline_cmd_desc##func                                            \</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>        };</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span> </div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"><a class="line" href="structsl__register__func__t.html">   89</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span></div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>{</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>    <span class="comment">/*int 为getc的返回值-1 为失败 其余为获得的值,裸机中必须配置为非阻塞的*/</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    int (*getc) (void); </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>    <span class="comment">/*int 为putc的返回值-1 为失败 其余为输出的值 char为输出值*/</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    int (*putc) (char); </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>}<a class="code hl_struct" href="structsl__register__func__t.html">sl_register_func_t</a>;</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span> </div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"><a class="line" href="structsl__dis__t.html">  101</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>{</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>    <span class="keywordtype">char</span> buff[SL_HIS_FIFO_LEN];</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    <span class="keywordtype">int</span>  len;</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>}<a class="code hl_struct" href="structsl__dis__t.html">sl_dis_t</a>;</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span> </div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"><a class="line" href="structsl__env__t.html">  111</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>{</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>    <span class="keywordtype">int</span> status;                       <span class="comment">/*sl的状态,0表示启用,非0表示不启用*/</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>    <a class="code hl_struct" href="structsl__register__func__t.html">sl_register_func_t</a> func;          <span class="comment">/*当前的注册函数*/</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>    <a class="code hl_struct" href="structsl__dis__t.html">sl_dis_t</a> dis;                     <span class="comment">/*显示指令储存*/</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dis_cursor;          <span class="comment">/*显示光标位置*/</span></div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    <a class="code hl_struct" href="structsl__dis__t.html">sl_dis_t</a> his[SL_HIS_FIFO_NUM];    <span class="comment">/*历史指令fifo*/</span></div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> his_cursor;          <span class="comment">/*历史光标位置*/</span></div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> wkey_val;            <span class="comment">/*记录多字符按键值*/</span></div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>}<a class="code hl_struct" href="structsl__env__t.html">sl_env_t</a>;</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span> </div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span><span class="comment">/*创建sline对象*/</span></div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span>SL_API <span class="keywordtype">int</span> <a class="code hl_function" href="sline_8h.html#ae065dfbcedba61e21f9e9e304d7795a5">sl_create</a>(<a class="code hl_struct" href="structsl__register__func__t.html">sl_register_func_t</a> * sl_rfunc);</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span><span class="comment">/*关闭sline对象*/</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>SL_API <span class="keywordtype">void</span> <a class="code hl_function" href="sline_8h.html#a05b3ad1d3093030ebdd5bf0cc987e63d">sl_delete</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span><span class="comment">/*等待处理命令输入*/</span></div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span>SL_API <span class="keywordtype">int</span> <a class="code hl_function" href="sline_8h.html#a5ead531b150a3e68774f187692062f7d">sl_waitcmd</a> (<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span><span class="comment">/*组件打印函数*/</span></div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span>SL_API <span class="keywordtype">int</span> <a class="code hl_function" href="sline_8h.html#a138f18399b17ee2ad2280ee3a1b2b2b1">sl_printf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *format,...);</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span><span class="comment">/*在函数内注册指令*/</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>SL_API <span class="keywordtype">int</span> <a class="code hl_function" href="sline_8h.html#a12763c56194a8fcadefe9bef7822f9ab">sl_cmd_export_pre</a>(<span class="keywordtype">char</span>* name,<span class="keywordtype">void</span> * func,<span class="keywordtype">char</span> *desc);</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span><span class="comment">/*在函数外注册指令*/</span></div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span><span class="comment">/* SL_API SL_CMD_EXPORT(func,desc) */</span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span> </div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>}</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span> </div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span><span class="preprocessor">#endif </span><span class="comment">/*__SLINE_H__*/</span><span class="preprocessor"></span></div>
<div class="ttc" id="asline_8h_html_a05b3ad1d3093030ebdd5bf0cc987e63d"><div class="ttname"><a href="sline_8h.html#a05b3ad1d3093030ebdd5bf0cc987e63d">sl_delete</a></div><div class="ttdeci">SL_API void sl_delete(void)</div><div class="ttdoc">关闭sline对象</div><div class="ttdef"><b>Definition:</b> sline.c:619</div></div>
<div class="ttc" id="asline_8h_html_a12763c56194a8fcadefe9bef7822f9ab"><div class="ttname"><a href="sline_8h.html#a12763c56194a8fcadefe9bef7822f9ab">sl_cmd_export_pre</a></div><div class="ttdeci">SL_API int sl_cmd_export_pre(char *name, void *func, char *desc)</div><div class="ttdoc">在环境中注册指令 注意调用在sl_create之前，否则不会被注册</div><div class="ttdef"><b>Definition:</b> sline.c:48</div></div>
<div class="ttc" id="asline_8h_html_a138f18399b17ee2ad2280ee3a1b2b2b1"><div class="ttname"><a href="sline_8h.html#a138f18399b17ee2ad2280ee3a1b2b2b1">sl_printf</a></div><div class="ttdeci">SL_API int sl_printf(const char *format,...)</div><div class="ttdoc">组件打印函数</div><div class="ttdef"><b>Definition:</b> sline.c:68</div></div>
<div class="ttc" id="asline_8h_html_a5ead531b150a3e68774f187692062f7d"><div class="ttname"><a href="sline_8h.html#a5ead531b150a3e68774f187692062f7d">sl_waitcmd</a></div><div class="ttdeci">SL_API int sl_waitcmd(void)</div><div class="ttdoc">等待处理命令输入</div><div class="ttdef"><b>Definition:</b> sline.c:523</div></div>
<div class="ttc" id="asline_8h_html_ae065dfbcedba61e21f9e9e304d7795a5"><div class="ttname"><a href="sline_8h.html#ae065dfbcedba61e21f9e9e304d7795a5">sl_create</a></div><div class="ttdeci">SL_API int sl_create(sl_register_func_t *sl_rfunc)</div><div class="ttdoc">创建sline对象</div><div class="ttdef"><b>Definition:</b> sline.c:594</div></div>
<div class="ttc" id="astructsl__dis__t_html"><div class="ttname"><a href="structsl__dis__t.html">sl_dis_t</a></div><div class="ttdoc">当前显示数据结构体</div><div class="ttdef"><b>Definition:</b> sline.h:102</div></div>
<div class="ttc" id="astructsl__env__t_html"><div class="ttname"><a href="structsl__env__t.html">sl_env_t</a></div><div class="ttdoc">sline对象的环境结构体</div><div class="ttdef"><b>Definition:</b> sline.h:112</div></div>
<div class="ttc" id="astructsl__register__func__t_html"><div class="ttname"><a href="structsl__register__func__t.html">sl_register_func_t</a></div><div class="ttdoc">注册sline对象所需要的字符收发函数 这部分接口更为与标准C一致</div><div class="ttdef"><b>Definition:</b> sline.h:90</div></div>
<div class="ttc" id="astructsline__cmd__code__t_html"><div class="ttname"><a href="structsline__cmd__code__t.html">sline_cmd_code_t</a></div><div class="ttdoc">代码段命令的对象结构体</div><div class="ttdef"><b>Definition:</b> sline.h:65</div></div>
<div class="ttc" id="astructsline__cmd__t_html"><div class="ttname"><a href="structsline__cmd__t.html">sline_cmd_t</a></div><div class="ttdoc">命令的对象结构体</div><div class="ttdef"><b>Definition:</b> sline.h:51</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
</small></address>
</body>
</html>
